<template>
    <div class="container add-form">
        <add-form :params="params" :formName="formName" :pageType="pageType" :values="values" @on-mounted="mounted"></add-form>
        <div class="button-region">
            <el-button size="small" class="button form-button cancel" @click="$router.back()">返回</el-button>
            <el-button type="primary" size="small" class="button form-button confirm" @click="submit">保存</el-button>
        </div>
    </div>
</template>
<script>
import { AddForm } from 'party_fe_component/src/components/dynamicForm';
import dataFormatter from '../../common/dataFormatter';
export default {
    props: {

    },
    data () {
        return {
            params: {},
            values: {}
        }
    },
    mounted () {
        this.setParams();
    },
    methods: {
        setParams: function () {
            const { orgLabel, parentId } = this;
            if (orgLabel && parentId) {
                this.params = {
                    requestParams: {
            			url: '/orginfo/department',
            			method: 'get',
            			params: {
            				groupId: parentId,
            				orgLabel
            			}
                    }
                };
            }
        },
        mounted: function (form) {
            this.$f = form;
        },
        formatSubmitData: function (formName, formData) {
            const formatter = dataFormatter['submit'][formName] || dataFormatter['submit']['common'];
            return formatter(formData);
        }
    },
    computed: {
        orgLabel: function () {
            return this.$route.query.orgLabel;
        },
        parentOrgId: function () {
            return this.$route.query.parentOrgId;
        },
        parentOrgName: function () {
            return this.$route.query.parentOrgName;
        },
        rootId: function () {
            return this.$route.query.rootId;
        },
        parentId: function () {
            return this.$route.query.parentId;
        },
        parentName: function () {
            return this.$route.query.parentName;
        },
        formName: function () {
            return this.$route.query.formName;
        },
        pageType: function () {
            return this.$route.query.pageType;
        }
    },
    components: { AddForm }
}
</script>
<style scoped lang="scss">
    @import '@/css/baseForm.scss';
</style>
